﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Frame.Lib.Core.Attach;
using Cms.Entity.Menu;
using Frame.Lib.Common;

namespace Cms.Entity.Article
{
    public partial class ArticleInfo
    {
        public ArticleInfo()
        {
            this.GetAttachs = id => null;
            this.GetPictures = id => null;
            this.GetMenuInfo = id => null;
        }       
    

        public Func<int, List<ImageInfo>> GetPictures;
        private List<ImageInfo> _pictures;
        public List<ImageInfo> Pictures
        {
            get
            {
                if (_pictures == null)
                {
                    _pictures = GetPictures(this.ID);
                }
                return _pictures;
            }
            set
            {
                _pictures = value;
            }
        }

        public Func<int, IEnumerable<AttachInfo>> GetAttachs;
        private IEnumerable<AttachInfo> _attach;
        public IEnumerable<AttachInfo> Attachs
        {

            get
            {
                if (_attach == null)
                {
                    _attach = GetAttachs(this.ID);
                }
                return _attach;
            }
            set
            {
                _attach = value;
            }
        }


        public Func<int, MenuInfo> GetMenuInfo;
        private MenuInfo _menuInfo;
        public MenuInfo MenuInfo
        {
            get
            {
                if (_menuInfo == null)
                {
                    _menuInfo = GetMenuInfo(this.MenuID);
                }
                return _menuInfo;
            }
            set
            {
                _menuInfo = value;
            }
        }

        public string SmallImageAbsPath
        {
            get
            {
                if (!string.IsNullOrEmpty(this.SmallImage))
                {
                    return GlobalVar.WebAppPath + this.SmallImage;
                }
                else
                {
                    return this.SmallImage;
                }
            }
        }
        public string BigImageAbsPath
        {
            get
            {
                if (!string.IsNullOrEmpty(this.BigImage))
                {
                    return GlobalVar.WebAppPath + this.BigImage;
                }
                else
                {
                    return this.BigImage;
                }
            }
        }

        public int PictureCount
        {
            get;
            set;
        }

    }
}
